var querDetialUrl = "../loanJournal/findByLoanId.action";

/*-------------------------页面加載------------------------------*/
var loadsoftDetInfo = function(id) {
	util.emmAjax({
		url : querDetialUrl,
		type : 'post',
		data : {
			'loanId' : id
		},
		cache : false,
		dataType : 'text',
		success : function(data) {
			var obj = util.str2Json(data); 
			if(obj.success=='true')
			{
				var loanJournals = obj.data;
				var htmls = "<article>";
				var nowYear="";
				if(loanJournals!=null)
				{
					for(var i =0;i<loanJournals.length;i++)
					{
						var loanJournal=loanJournals[i];
						if(nowYear!=loanJournal.curProcessUpdateYear)
						{
							nowYear=loanJournal.curProcessUpdateYear;
							htmls += "<h3>"+nowYear+"年</h3>";
						}
						htmls+="<section style=\"font-size:14px;\"> <span class=\"point-time point-blue\"></span>"+
								"<time datetime=\"\"> <span style=\"padding-top:10px;\">"+loanJournal.curProcessUpdateDate+"</span> </time>"+
								"<aside style=\"padding-top:10px;padding-right:100px;\"> <p class=\"things\" >"+loanJournal.remark+"</p> </aside> </section>";
					}
				}
				else{
					
					htmls+="<h4>无历史记录！</h4>";
				}
				
				htmls+="</article>";
				//alert(htmls);
				$("#historyRout").html(htmls);
				
				
			}
			else
				{
					util.sysAlert(obj.data);
				}
		}
	});
};
/*
 * 获取url参数
 */
var getUrlParam=function(name) {
	 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	 var urlParam = window.location.search.substr(1);
	 var r = decodeURI(urlParam).match(reg);  //匹配目标参数
	 if (r != null) return unescape(r[2]); return null; //返回参数值

};

$(function(){
	var loanId = getUrlParam('loanId');
	loadsoftDetInfo(loanId);
	
});

/**
 *将json字符串转化为json对象
 */
function str2Json(jsonStr){
	var json = eval("(" + jsonStr + ")"); 
	return json;
};